<template>
	<view class="goods-page-item">
		<!-- 左边的图片盒子 -->
		<view class="goods-page-left">
			<radio  class="goods-radio" v-if="showRadio" :checked="goods.goods_state" color="#c00000" @click="change"></radio>
			<image class="goods-page-image" :src="goods.goods_small_logo || defaultImg" mode=""></image>
		</view>
		<!-- 右边的文字内容区域 -->
		<view class="goods-list-content">
			<view class="goods-page-title">{{goods.goods_name}}</view>
			<view class="goods-list-metion">
				<view class="goods-page-price">￥{{Number(goods.goods_price).toFixed(2)}}</view>
				<uni-number-box v-if="showNumBox" class="goods-number-area" :value="goods.goods_count" :min="1" :max="100" @change="changeNum"></uni-number-box>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name:"my-goods",
		data() {
			return {
				defaultImg: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png', // 默认图片
			};
		},
		props:{
			goods:{
				type: Object,
				default:{}
			},
			showRadio:{
				type:Boolean,
				default: false,
			},
			showNumBox:{
				type:Boolean,
				default:false
			}
		}, 
		methods:{
			change(){
				this.$emit('checkThis',{
					goods_type: 'check',
					goods_state:!this.goods.goods_state,
					goods_id:this.goods.goods_id
				})
			},
			// 改变输入框中的值
			changeNum(e){
				// console.log('123',e)
				this.$emit('checkThis',{
					goods_type: 'num',
					goods_count:+e,
					goods_id:this.goods.goods_id
				})
			}
		}
	}
</script>

<style lang="scss">
.goods-page-item{
		background-color: #fff;
		display: flex;
		align-items: center;
		padding: 10rpx 0;
		border-bottom: 1px solid #eee;
		.goods-page-left{
			display: flex;
			align-items: center;
			
			margin-right: 10rpx;
			
			.goods-radio{
				width: 50rpx;
				height: 50rpx;
				margin-right: 5rpx;
				margin-left: 10rpx;
			}
			.goods-page-image{
				width: 100px;
				height: 100px;
			}
			
		}
		.goods-list-content{
			height: 100px;
			display: flex;
			flex-direction: column;
			// justify-content: space-around;
			justify-content: space-between;
			// align-items: space-between;
			// flex-wrap: wrap;
			.goods-page-title{
				font-size: 26rpx;
			}
			.goods-list-metion{
				display: flex;
				justify-content: space-between;
				align-items: center;
				.goods-page-price{
					font-size: 34rpx;
					color: #c00000;
				}
				.goods-number-area{
					margin-right: 10rpx;
				}
			}
		}
		
	}
</style>